package com.yedean.mall.api;

import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.Data;

import java.util.List;

/**
 * CommonPage
 *
 * @author yedean
 * @date 2022/8/3
 */
@Data
public class CommonPage<T> {

    private Long pageNum;
    private Long pageSize;
    private Long totalPage;
    private Long total;
    private List<T> list;


    public static <T> CommonPage<T> resetPage(IPage<T> pageInfo) {
        CommonPage<T> result = new CommonPage<>();
        result.setTotal(pageInfo.getTotal());
        result.setPageNum(pageInfo.getCurrent());
        result.setPageSize(pageInfo.getSize());
        result.setTotalPage(pageInfo.getPages());
        result.setList(pageInfo.getRecords());

        return result;
    }
}
